package com.g0dkar.leet.core.model;

import java.io.Serializable;
import java.lang.reflect.Method;

/**
 * Pure-Java mapping representing one persistent attribute of a {@link ClassMapping MetaClass}.
 * 
 * @see ClassMapping
 * @author Daniel Mário
 * @author Rafael g0dkar Lins
 */
public class Property implements Serializable, Cloneable {
	/**
	 * Serial Version ID: 1.0
	 */
	private static final long serialVersionUID = 1L;
	
	private String displayName;
	private String name;
	private String className;
	private String minValue;
	private String maxValue;
	private String defaultValue;
	private boolean notNull;
	private boolean unique;
	
	private Class<?> type;
	private Method getter;
	private Method setter;
	
	/**
	 * @return the name of this attribute.
	 */
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * @return the minimal acceptable value of this attribute.
	 */
	public String getMinValue() {
		return minValue;
	}
	
	public void setMinValue(String minValue) {
		this.minValue = minValue;
	}
	
	/**
	 * @return the maximum acceptable value of this attribute.
	 */
	public String getMaxValue() {
		return maxValue;
	}
	
	public void setMaxValue(String maxValue) {
		this.maxValue = maxValue;
	}
	
	/**
	 * @return the default value of this attribute.
	 */
	public String getDefaultValue() {
		return defaultValue;
	}
	
	public void setDefaultValue(String defaultValue) {
		this.defaultValue = defaultValue;
	}
	
	/**
	 * @return true if this attribute's value can be null.
	 */
	public boolean isNotNull() {
		return notNull;
	}
	
	public void setNotNull(boolean notNull) {
		this.notNull = notNull;
	}
	
	/**
	 * @return true if this attribute can't be equals in more than one instance of the entity represented by the
	 *         MetaClass holding this MetaProperty.
	 * @see ClassMapping
	 */
	public boolean isUnique() {
		return unique;
	}
	
	public void setUnique(boolean unique) {
		this.unique = unique;
	}
	
	/**
	 * @return the POJO getter of this attribute.
	 */
	public Method getGetter() {
		return getter;
	}
	
	public void setGetter(Method getter) {
		this.getter = getter;
	}
	
	/**
	 * @return the POJO setter of this attribute.
	 */
	public Method getSetter() {
		return setter;
	}
	
	public void setSetter(Method setter) {
		this.setter = setter;
	}
	
	/**
	 * Returns the actual {@link Class} of this attribute.
	 * 
	 * @return The actual {@link Class} of this attribute.
	 */
	public Class<?> getType() {
		return type;
	}
	
	public void setType(Class<?> type) {
		this.type = type;
	}
	
	/**
	 * @return Fully qualified name of this attribute's {@link Class}.
	 */
	public String getClassName() {
		return className;
	}
	
	public void setClassName(String className) {
		this.className = className;
	}

	public String getDisplayName() {
		return displayName;
	}

	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}
}
